﻿// ReSharper disable CppClangTidyClangDiagnosticSwitchEnum
#include "pch.h"
#include "AbstractShader.h"

#include "function/RenderSystem/AbstractRenderer.h"
#include "function/RenderSystem/OpenGL/OpenGLShader.h"

namespace Engine
{
	Ref<AbstractShader> AbstractShader::Create(const std::string& filepath)
	{
		switch (AbstractRenderer::GetAPI())
		{
		case RendererAPI::API::None:
			ENGINE_ASSERT(false, "无 Renderer API！")
				return nullptr;
#if PLATFORM_WINDOWS
		case RendererAPI::API::OpenGL:
			return CreateRef<OpenGLShader>(filepath);
		case RendererAPI::API::Direct3D:
			return nullptr;
		case RendererAPI::API::Vulcan:
			return nullptr;
#elif PLATFORM_MAC
		case RendererAPI::Metal:
			return nullptr;
#endif
		default:
			ENGINE_ASSERT(false, "未知的 Renderer API！")
				return nullptr;
		}
	}

	Ref<AbstractShader> AbstractShader::Create(std::string& name, const std::string& vertexSrc,
	                                           const std::string& fragmentSrc)
	{
		switch (AbstractRenderer::GetAPI())
		{
		case RendererAPI::API::None:
			ENGINE_ASSERT(false, "无 Renderer API！")
			return nullptr;
#if PLATFORM_WINDOWS
		case RendererAPI::API::OpenGL:
			return CreateRef<OpenGLShader>(name, vertexSrc, fragmentSrc);
		case RendererAPI::API::Direct3D:
			return nullptr;
		case RendererAPI::API::Vulcan:
			return nullptr;
#elif PLATFORM_MAC
		case RendererAPI::Metal:
			return nullptr;
#endif
		default:
			ENGINE_ASSERT(false, "未知的 Renderer API！")
			return nullptr;
		}
	}
}
